<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js">
		</script>
		<title></title>
		
		<style>
		    pre {outline: 1px solid #ccc; padding: 5px; margin: 5px;font-family: '微软雅黑';}
		    .string { color: green; }
		    .number { color: darkorange; }
		    .boolean { color: blue; }
		    .null { color: magenta; }
		    .key { color: red; }
		</style>

	</head>
	<body style="font-family: '微软雅黑';">
		
		
		
		<button id="menufirst"> 菜品首页推荐 </button>
		<button id="addview"> 添加菜品访问记录 </button>
		<button id="menubtn"> 菜品列表 </button>
		<button id="menumsg"> 菜品详情 </button>
		
		<br>
		<br>
		<button id="praise"> 点赞 </button>
		<button id="ispraise"> 是否点赞过 </button>
		
		<br>
		<br>
		<button id="marketlist"> 菜场列表 </button>
		<button id="marketmenu"> 菜场的菜 </button>
		<button id="marketmap"> 菜场地图 </button>
		<!--<button id="marketmsg"> 菜场详情 </button>-->
		<br>
		<br>
		<button id="commoditymsg">菜详情页面</button>
		<button id="commodityprice">菜价列表</button>
		
		<br>
		<br>
		<button id="commentbtn">评价</button>	
		<button id="mcomment">菜场综合评价</button>
		<button id="iscommentbtn"> 是否评价 </button>
		
		<br>
		<br>
		<button id="newloginbtn"> 登录获得userid  </button>
		
		
		<br>
		<br>
		<pre id="msgView">

		</pre>
	</body>
	
	<script>
		var topHost = 'http://192.168.2.232:8087/';
		
		$("#menufirst").click(
			function(){
				jQuery.get(topHost+"menu",{},function(respdata){
					console.log('res='+respdata);	
					$("#msgView").html(syntaxHighlight(respdata));
				});
			}
		);
		
		
		$("#addview").click(
			//menu/viewcount/{id}
			// id 菜单id
			function(){
				jQuery.post(topHost+"menu/viewcount/21",{},function(respdata){
					console.log('res='+respdata);	
					$("#msgView").html(syntaxHighlight(respdata));
				});
			}
		);
		
		$("#menubtn").click(
			//page 分页。第一页为1  每页20条
			function(){
				jQuery.get(topHost+"menu/list",{page:3,keyword:'菜'},function(respdata){
					console.log('res='+respdata);	
					$("#msgView").html(syntaxHighlight(respdata));
				});
			}
		);
		
		$("#menumsg").click(
			//menu/{id}
			//id 菜单id
			function(){
				jQuery.get(topHost+"menu/21",{},function(respdata){
					console.log('res='+respdata);	
					$("#msgView").html(syntaxHighlight(respdata));
				});
			}
		);
		
		$("#praise").click(
			///personal/praise/user/{uid}/type/{type}/sourceId/{sourceId}
			//uid 用户编号
			//type 点赞类型，1：菜谱
			//sourceId 菜单id
			function(){
				jQuery.post(topHost+"personal/praise/user/13/type/2/sourceId/14",{},function(respdata){
					console.log('res='+respdata);	
					$("#msgView").html(syntaxHighlight(respdata));
				});
			}
		);
		
		$("#ispraise").click(
			function(){
				jQuery.get(topHost+"personal/praise/user/13/type/2/sourceId/14",{},function(respdata){
					console.log('res='+respdata);	
					
					//result:false 每页被点赞
					//result 为一个 object 为返回的数据
					
					$("#msgView").html(syntaxHighlight(respdata));
				});
			}
		);
		
		$("#marketlist").click(
			function(){
				jQuery.get(topHost+"market",{},function(respdata){
					console.log('res='+respdata);	
					$("#msgView").html(syntaxHighlight(respdata));
				});
			}
		);
		
		$("#marketmenu").click(
			
			//market/{marketId}/items
			//marketId 菜场编号
			function(){
				jQuery.get(topHost+"market/1017/items",{},function(respdata){
					console.log('res='+respdata);	
					$("#msgView").html("<span style='color:blue;'>图片路径为 http://ptmarket.dashenw.cn/images/菜的commodityId.jpg<span><br><br>"+syntaxHighlight(respdata));
				});
			}
		);
		
		
		$("#marketmap").click(
			
			//market/map/{marketId}
			//marketId 菜场编号
			function(){
				jQuery.get(topHost+"market/map/1017",{},function(respdata){
					console.log('res='+respdata);	
					$("#msgView").html(syntaxHighlight(respdata));
				});
			}
		);
		
		$("#marketmsg").click(
			
			///market/{id}
			//id 菜场编号
			function(){
				jQuery.get(topHost+"market/1017",{},function(respdata){
					console.log('res='+respdata);	
					$("#msgView").html(syntaxHighlight(respdata));
				});
			}
		);
		
		$("#commoditymsg").click(
			
			//commodity/{cid}/type/{typeId}
			//cid 菜场对应菜品的 commodityId
			//typeId 菜场对应菜品分类的 typeId
			function(){
				jQuery.get(topHost+"commodity/900010/type/CC107",{},function(respdata){
					console.log('res='+respdata);	
					$("#msgView").html(syntaxHighlight(respdata));
				});
			}
		);
		
		$("#commodityprice").click(
			
			///commodity/{cid}/type/{typeId}/data
			//cid 菜场对应菜品的 commodityId
			//typeId 菜场对应菜品分类的 typeId
			function(){
				jQuery.get(topHost+"commodity/900010/type/CC107/data",{},function(respdata){
					console.log('res='+respdata);	
					$("#msgView").html(syntaxHighlight(respdata));
				});
			}
		);
		
		$("#commentbtn").click(
			//comment
			
//			{marketid:菜场编号,marketname:菜场名字,star:星星,uid:用户编号,name:'用户昵称',message:'评价详情',tag:'评价标签'}
			
			function(){
				jQuery.get(topHost+"comment",{marketid:1019,marketname:'桃浦菜场',star:5,uid:110,name:'爱你',message:'爱你一万年爱你一万年,爱你一万年爱你一万年爱你一万年爱你一万年爱你一万年爱你一万年一万年爱你一万年',tag:'干净卫生,干净卫生,简介大方,净卫生,简介大方,干净卫生,干净卫生,简介大方,净卫生,简介大方,干净卫生,简介大方'},function(respdata){
					console.log('res='+respdata);	
					$("#msgView").html(syntaxHighlight(respdata));
				});
			}
		);
		
		$("#mcomment").click(
			//comment
			
//			{marketid:菜场编号,marketname:菜场名字,star:星星,uid:用户编号,name:'用户昵称',message:'评价详情',tag:'评价标签'}
			
			function(){
				jQuery.get(topHost+"mcomment",{marketid:1018},function(respdata){
					console.log('res='+respdata);	
					$("#msgView").html(syntaxHighlight(respdata));
				});
			}
		);
		
		$("#iscommentbtn").click(
			
			function(){
				jQuery.get(topHost+"iscomment",{marketid:1018,uid:110},function(respdata){
					console.log('res='+respdata);	
					$("#msgView").html(syntaxHighlight(respdata));
				});
			}
			
		);
		
		$("#newloginbtn").click(
			
			function(){
				jQuery.get(topHost+"newlogin",{},function(respdata){
					console.log('res='+respdata);	
					$("#msgView").html(syntaxHighlight(respdata));
				});
			}
			
		);
		
		function syntaxHighlight(json) {
		    if (typeof json != 'string') {
		        json = JSON.stringify(json, undefined, 2);
		    }
		    json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
		    return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function(match) {
		        var cls = 'number';
		        if (/^"/.test(match)) {
		            if (/:$/.test(match)) {
		                cls = 'key';
		            } else {
		                cls = 'string';
		            }
		        } else if (/true|false/.test(match)) {
		            cls = 'boolean';
		        } else if (/null/.test(match)) {
		            cls = 'null';
		        }
		        return '<span class="' + cls + '">' + match + '</span>';
		    });
		}
		
	</script>
</html>
